#include <iostream>
#include <stdio.h>
#include <set>
using namespace std;

bool cmp(multiset<int> s1, multiset<int> s2) {
    if (s1.size() > s2.size()) swap(s1, s2);
    for (multiset<int>::iterator it1 = s1.begin(); it1 != s1.end(); ++it1) {
        int t = *it1;
        if (s1.count(t) != s2.count(t)) return false;
    }
    return true;
}
bool cmp(set<int> s1, set<int> s2) {
    if (s1.size() != s2.size()) return false;
    for (set<int>::iterator it1=s1.begin(), it2=s2.begin(); it1 != s1.end(); ++it1, ++it2) {
        if ((*it1) != (*it2)) return false;
    }
    return true;
}

int main(int argc, char** argv) {
#ifdef hai
    freopen("in.txt", "r", stdin);
#endif
    int a,b;
    while (~scanf("%d %d", &a, &b)) {
        if (a==-1 || b==-1) break;
        multiset<int> s1,s2;
        set<int> s11,s21;
        int t;
        for (int i=0; i<a; ++i) {
            scanf("%d", &t);
            s11.insert(t);
            if (t&1) {
                s1.insert(t);
                s11.insert(2*t+2);
            }
        }
        for (int i=0; i<b; ++i) {
            scanf("%d", &t);
            s21.insert(t);
            if (t&1) {
                s2.insert(t);
                s21.insert(2*t+2);
            }
        }
        if (cmp(s11, s21) && cmp(s1, s2)) {
            printf("Y\n");
        } else {
            printf("N\n");
        }
    }
    return 0;
}
